/**
 *
 */
package de.cbf.cam.dice.entities;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;

/**
 * @author Surfer
 *
 */
public class RollData {
	public static final int PropertyIndexName	 		 = 2;
	public static final int PropertyIndexDiceSides 		 = 3;
	public static final int PropertyIndexRolls			 = 4;


	protected String  	name 		;
	protected int[]		diceSides	;
	protected int[]		rolls 		;


	public PropertyChangeSupport propertyChange ;

	public RollData() {
		super();
		name 			= "";
		diceSides 		= new int[1];
		rolls 			= new int[1];
		propertyChange 	= new PropertyChangeSupport(this);
	}


//===================
//		public methods
//===================

	public void removeAllPropertyChangeListeners() {
		PropertyChangeListener[] listeners = propertyChange.getPropertyChangeListeners();
		for (int i = 0; i < listeners.length; i++) {
			propertyChange.removePropertyChangeListener(listeners[i]);
//			if (listeners[i] instanceof ListenerLogic) {
//				ListenerLogic listenerLogic = (ListenerLogic) listeners[i];
//				listenerLogic.removeSelf();
//			}
		}
	}

	@Override
	public String toString() {
		return name+diceSides;
	}

//===================
//		field access
//===================

	public String getName() {
		return name;
	}

	public void setName(String name) {
		if( ! this.name.equals(name)){
			this.name = name;
			propertyChange.fireIndexedPropertyChange("Name",PropertyIndexName,null,name);
		}
	}



	public int[] getRolls() {
		return rolls;
	}

	public void setRolls(int[] rolls) {
//		boolean same = Util.intArrayCompare(this.rolls,rolls);
//		if(!same){
//			this.rolls = rolls;
//			propertyChange.fireIndexedPropertyChange("Rolls",PropertyIndexRolls,null,rolls);
//		}
	}


	public int[] getDiceSides() {
		return diceSides;
	}

	public void setDiceSides(int[] diceSides) {
//		boolean same = Util.intArrayCompare(this.diceSides,diceSides);
//		if(!same){
//			this.diceSides = diceSides;
//			propertyChange.fireIndexedPropertyChange("DiceSides",PropertyIndexDiceSides,null,diceSides);
//		}
	}


}
